<template>
  <div>
    <div class="title">推荐歌单</div>
    <!-- 放图片的盒子 -->
    <div class="pic-box">
      <van-row gutter="5">
        <van-col v-for="item in list" :key="item.id" span="8">
          <img style="width: 100%; height: 120px" :src="item.picUrl" alt="" />
          <div class="song_name">{{ item.name }}</div>
        </van-col>
      </van-row>
    </div>
    <!-- 最新音乐 -->
    <div class="list_box">
      <div class="title">最新音乐</div>
      <van-cell-group>
        <music-cell
          v-for="item in musicList"
          :key="item.id"
          :id="item.id"
          :title="item.name"
          :label="`${item.song.artists[0].name} - ${item.name}`"
        ></music-cell>
      </van-cell-group>
    </div>
  </div>
</template>

<script>
import { recommendAPI, newList } from "@/API/home";
import musicCell from "@/components/musicCell.vue";

export default {
  components: { musicCell },
  data() {
    return {
      list: [],
      musicList: [],
    };
  },
  async created() {
    const res = await recommendAPI({
      limit: 6,
    });
    // console.log(res);
    this.list = res.data.result;
    //更新列表
    const res2 = await newList();
    this.musicList = res2.data.result;
    // console.log(res2);
  },
};
</script>

<style>
/* 标题 */
.title {
  padding: 10px 15px;
  margin: 0 0 15px 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  height: 45px;
  font-size: 16px;
  padding: 0 5px;
  margin-bottom: 10px;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
</style>